package com.controller;

import com.github.pagehelper.PageInfo;
import com.model.*;
import com.query.PlatformFlowQuery;
import com.service.finance.FinanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author biao.yang
 * @Description: 财务管理
 * @date 2021/4/17 11:59
 */
@RestController
@RequestMapping("/finance")
@Api(tags = "财务管理模块", value = "财务管理模块相关api")
public class FinanceController {

    @Autowired
    private FinanceService financeService;

    @PostMapping("/platform/flow")
    @ApiOperation(value = "平台流水")
    public ReponseDto<PageInfo<TransferRecdModel>> platformFlow(@RequestBody PlatformFlowQuery query){
        return new ReponseDto<>(financeService.platformFlow(query));
    }

    @GetMapping("/withdraw/flow/list")
    @ApiOperation(value = "提币流水-列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = false),
            @ApiImplicitParam(name = "coinSymbol", value = "币种", required = false),
            @ApiImplicitParam(name = "pageNo", value = "分页条码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true)
    })
    public ReponseDto<PageInfo<DrawithRecdModel>> withdrawFlowList(@RequestParam(value = "name",required = false) String name,
                                 @RequestParam(value = "coinSymbol",required = false) String coinSymbol,
                                 @RequestParam(value = "pageNo",required = true) String pageNo,
                                 @RequestParam(value = "pageSize",required = true) Integer pageSize){
        return new ReponseDto<>(financeService.withdrawFlowList(name,coinSymbol,pageNo,pageSize));
    }

    @GetMapping("/withdraw/review/list")
    @ApiOperation(value = "提币审核-列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = false),
            @ApiImplicitParam(name = "coinSymbol", value = "币种", required = false),
            @ApiImplicitParam(name = "status", value = "状态 1待审核 2已审核", required = true),
            @ApiImplicitParam(name = "pageNo", value = "分页条码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true)
    })
    public ReponseDto<PageInfo<DrawithRecdModel>> withdrawReviewList(@RequestParam(value = "name",required = false) String name,
                                   @RequestParam(value = "coinSymbol",required = false) String coinSymbol,
                                   @RequestParam(value = "status") Integer status,
                                   @RequestParam(value = "pageNo",required = true) String pageNo,
                                   @RequestParam(value = "pageSize",required = true) Integer pageSize){
        return new ReponseDto<>(financeService.withdrawReviewList(name,coinSymbol,status,pageNo,pageSize));
    }

    @GetMapping("/withdraw/review/operate")
    @ApiOperation(value = "提币审核-操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据id", required = true),
            @ApiImplicitParam(name = "status", value = "状态 1通过 2不通过", required = true)
    })
    public ReponseDto withdrawReviewOperate(@RequestParam(value = "id") Long id,@RequestParam(value = "status") Integer status){
        financeService.withdrawReviewOperate(id,status);
        return new ReponseDto<>();
    }

    @GetMapping("/withdraw/roll/list")
    @ApiOperation(value = "提币券管理-列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = false),
            @ApiImplicitParam(name = "pageNo", value = "分页条码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true)
    })
    public ReponseDto<PageInfo<ExtractTicketModel>> withdrawRollList(@RequestParam(value = "name",required = false) String name,
                                 @RequestParam(value = "pageNo",required = true) String pageNo,
                                 @RequestParam(value = "pageSize",required = true) Integer pageSize){
        return new ReponseDto<>(financeService.withdrawRollList(name,pageNo,pageSize));
    }

    @GetMapping("/withdraw/roll/add")
    @ApiOperation(value = "提币券管理-新增")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true),
            @ApiImplicitParam(name = "num", value = "数量", required = true)
    })
    public ReponseDto withdrawRollAdd(@RequestParam(value = "userId",required = true) Long customerId,
                                      @RequestParam(value = "num",required = true) Integer num,
                                      @RequestHeader String userId,
                                      @RequestHeader String username) throws Exception{
        financeService.withdrawRollAdd(customerId,num,Long.parseLong(userId),username);
        return new ReponseDto<>();
    }

    @GetMapping("/blacklist")
    @ApiOperation(value = "黑名单管理-列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = false),
            @ApiImplicitParam(name = "pageNo", value = "分页条码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true)
    })
    public ReponseDto<PageInfo<BlacklistModel>> blacklist(@RequestParam(value = "name",required = false) String name,
                                                          @RequestParam(value = "pageNo",required = true) String pageNo,
                                                          @RequestParam(value = "pageSize",required = true) Integer pageSize){
        return new ReponseDto<>(financeService.blacklist(name,pageNo,pageSize));
    }

    @GetMapping("/blacklistAdd")
    @ApiOperation(value = "黑名单管理-新增")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true),
            @ApiImplicitParam(name = "type", value = "类型", required = false),
    })
    public ReponseDto blacklistAdd(@RequestParam(value = "userId",required = true) Long userIdDel,
                                   @RequestParam(value = "type",required = false) Integer type,
                                   @RequestHeader String userId, @RequestHeader String username) throws Exception{
        financeService.blacklistAdd(userIdDel,type,userId,username);
        return new ReponseDto<>();
    }

    @GetMapping("/blacklistDel")
    @ApiOperation(value = "黑名单管理-移除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据ID", required = true)
    })
    public ReponseDto blacklistDel(@RequestParam(value = "id",required = true) Long id, @RequestHeader String userId, @RequestHeader String username){
        financeService.blacklistDel(id,userId,username);
        return new ReponseDto<>();
    }

    @GetMapping("/account/list")
    @ApiOperation(value = "账号统计-列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = false),
            @ApiImplicitParam(name = "coinSymbol", value = "币种", required = false),
            @ApiImplicitParam(name = "pageNo", value = "分页条码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true)
    })
    public ReponseDto<PageInfo<CoinAddrModel>> accountList(@RequestParam(value = "name",required = false) String name,
                            @RequestParam(value = "coinSymbol",required = false) String coinSymbol,
                            @RequestParam(value = "pageNo",required = true) String pageNo,
                            @RequestParam(value = "pageSize",required = true) Integer pageSize){
        return new ReponseDto<>(financeService.accountList(name,coinSymbol,pageNo,pageSize));
    }

    @GetMapping("/verified/list")
    @ApiOperation(value = "实名认证审核-列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = false),
            @ApiImplicitParam(name = "number", value = "身份证号", required = false),
            @ApiImplicitParam(name = "status", value = "状态 1待审核 2已审核", required = true),
            @ApiImplicitParam(name = "pageNo", value = "分页条码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true),
    })
    public ReponseDto<PageInfo<CustomerAuthModel>> verifiedList(@RequestParam(value = "name",required = false) String name,
                                                                @RequestParam(value = "number",required = false) String number,
                                                                @RequestParam(value = "status",required = true) Integer status,
                                                                @RequestParam(value = "pageNo",required = true) String pageNo,
                                                                @RequestParam(value = "pageSize",required = true) Integer pageSize){

        return new ReponseDto<>(financeService.verifiedList(name,number,status,pageNo,pageSize));
    }

    @GetMapping("/verified/operate")
    @ApiOperation(value = "实名认证审核-操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据id", required = true),
            @ApiImplicitParam(name = "status", value = "状态 1通过 2不通过", required = true)
    })
    public ReponseDto verifiedOperate(@RequestParam(value = "id") Long id, @RequestParam(value = "status") Integer status, @RequestHeader String userId, @RequestHeader String username){
        financeService.verifiedOperate(id,status,userId,username);
        return new ReponseDto<>();
    }

}
